<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			
			// 获取手机系统信息
			const info = uni.getSystemInfoSync();
			// 设置状态栏高度
			 
		 
			// h5 app mp-alipay
			// #ifndef H5 || APP-PLUS || MP-ALIPAY
				// 获取胶囊的位置
				const menuButtonInfo = uni.getMenuButtonBoundingClientRect();
				// (胶囊底部高度 - 状态栏的高度) + (胶囊顶部高度 - 状态栏内的高度) = 导航栏的高度
				this.$store.state.navBarHeight = menuButtonInfo.bottom - info.statusBarHeight + (menuButtonInfo.top - info.statusBarHeight);
				
				this.menuButtonInfo = uni.getMenuButtonBoundingClientRect();
			// #endif
			  
			this.$store.state.statusBarHeight = info.statusBarHeight +  50;
			
			// 获取动态tabBar
			this.getMerchant();
		},
		onShow: function() {
			
			// uni.reLaunch({
			// 	url:'/pages/tabbar/index'
			// })
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods:{
			getMerchant(){
				//  获取一些配置
				this.tui.request("/basic-capi/wechatApi/getWechatConfig", "post").then((res) => {
					 if(res.code == 200){
						 this.$store.state.wechatConfig = JSON.parse(res.data.wx_config)
						 this.$store.state.themeConfig = res.data.theme_config
						 // 获取动态商户配置
						 this.getTabBar();
						
					 }
				}).catch((res) => {
					console.log(res)
				})
			},
			getTabBar(){
				this.$store.state.tabBarList = []
				var pagePath = ''
				var Https = this.$store.state.wechatConfig.tencent‌Domain
				this.$store.state.themeConfig.tabbar.forEach((item,index)=>{
					this.$store.state.tabBarList.push({
						pagePath:item.path,
						text:item.name,
						iconPath:Https + '/' +item.icon,
						selectedIconPath:Https +'/'+ item.selectIcon,
						hump:item.hump=='1'?true:false
					})
				})
			 
				setTimeout(()=>{
					uni.setStorageSync('tabbar',this.$store.state.tabBarList)
					uni.setStorageSync('themeConfig',this.$store.state.themeConfig)
					uni.setStorageSync('wechatConfig',this.$store.state.wechatConfig)
				},1000)
				
			}
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "@/uni_modules/uview-ui/index.scss";
	 
</style>
 